home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 December / PCWorld_2005-12_cd.bin / software / temacd / tiny / tpf-6[1].5.126.exe / Tiny Firewall 2005.msi / webui.dll / COMMON / SDB-DAYTIME.JS < prev    next >
Encoding:
JavaScript  |  2005-08-17  |  2.8 KB  |  96 lines

  1. /*//////////////////////////////////////////////////////////////////////
  2. Filename:          sdb-daytime.js
  3. Company Name:      Computer Associates International, Inc.
  4. Legal Copyright: Copyright (c) Computer Associates International, Inc.
  5. Author:          Ales Novak
  6. Product:          Tiny Firewall
  7. Description:      javascript code to manipulate time object through XMLSecDBParser COM iface
  8. ///////////////////////////////////////////////////////////////////////*/
  9.  
  10. // requires sdb-consts.js + sdb-msgs.js
  11.  
  12. ///////////////////////////////////////////////////////////////////////
  13. // AddPredefinedDayTimeObject - adds it to both FW and SBX at once
  14. //   the format of the strDayTimeIntervals is "Mo#9:0-17:59|Tu#9:0-17:59|We#9:0-17:59|Th#9:0-17:59|Fr#9:0-16:59"
  15. function AddPredefinedDayTimeObject( strDayTimeObjectID, strDayTimeIntervals )
  16. {
  17.     var bSuccess = false;
  18.  
  19.     // put it to FW database
  20.     try {
  21.         var definitionList = external.ServerParser(XM_FW).DefinitionList;
  22.  
  23.         var definition = definitionList.CreateDefinition();
  24.         definition.DefinitionID = strDayTimeObjectID;
  25.         definition.ObjectType = OT_TIME;
  26.  
  27.         var newItem = definition.ItemList.CreateItem();
  28.         newItem.Content = strDayTimeIntervals;
  29.         definition.ItemList.Insert(newItem);
  30.  
  31.         definitionList.Insert( definition );
  32.  
  33.         bSuccess = true;
  34.     }
  35.     catch(e) {}
  36.  
  37.     // put it to SBX database as well
  38.     try {
  39.         var definitionList = external.ServerParser(XM_SBX).DefinitionList;
  40.  
  41.         var definition = definitionList.CreateDefinition();
  42.         definition.DefinitionID = strDayTimeObjectID;
  43.         definition.ObjectType = OT_TIME;
  44.  
  45.         var newItem = definition.ItemList.CreateItem();
  46.         newItem.Content = strDayTimeIntervals;
  47.         definition.ItemList.Insert(newItem);
  48.  
  49.         definitionList.Insert( definition );
  50.  
  51.         bSuccess = true;
  52.     }
  53.     catch(e) {}
  54.  
  55.     external.Save();
  56.  
  57.     return (bSuccess ? SUCCESS : ErrorHandler( ERR_ADDING_TIME_OBJECT_FAILED, STR_ADDING_TIME_OBJECT_FAILED ));
  58. }
  59.  
  60. ///////////////////////////////////////////////////////////////////////
  61. // DeletePredefinedDayTimeObject - removes it from both FW and SBX at once
  62. function DeletePredefinedDayTimeObject( strDayTimeObjectID )
  63. {
  64.     var bSuccess = false;
  65.  
  66.     // remove it from FW database
  67.     try {
  68.         var definitionList = external.ServerParser(XM_FW).DefinitionList;
  69.  
  70.         var definition = definitionList.Get( strDayTimeObjectID );
  71.         if (definition)
  72.             definitionList.Remove(definition);
  73.  
  74.         bSuccess = true;
  75.     }
  76.     catch(e) {}
  77.  
  78.     // remove it from SBX database as well
  79.     try {
  80.         var definitionList = external.ServerParser(XM_SBX).DefinitionList;
  81.  
  82.         var definition = definitionList.Get( strDayTimeObjectID );
  83.         if (definition)
  84.             definitionList.Remove(definition);
  85.  
  86.         bSuccess = true;
  87.     }
  88.     catch(e) {}
  89.  
  90.     external.Save();
  91.  
  92.     return (bSuccess ? SUCCESS : ErrorHandler( ERR_DELETE_TIME_OBJECT_FAILED, STR_DELETE_TIME_OBJECT_FAILED ));
  93. }
  94.  
  95.  
  96.